﻿/**
 * Example Controller Class - just a basic framework for this class
 *
 * The Controller of the MVC Triad 
 *
 * @author  	robert turrall
 * @date	   	31.12.2008
 * @license: 	This particular file may be used freely. It serves simply as an example.
 * 				Of course, a credit is always nice ;-)
 *
 * @version	1.0
 */
package { 

	// please note that it's not really good practice to use the default package (i.e. none). 
	// You should normally save your classes in a package which corresponds to your application
	
	import net.turrall.mvc.*;
	//import your other package classes as required here
	import flash.events.*;
	
	public class ExampleController extends AbstractController {
		
		public function ExampleController(model:ExampleModel) {	
			
			super(model);
			
		}
		
		/**
		 * React to changes on the on-screen UI.
		 * Invoke the appropriate method in the model depending upon what just happened.
		 *
		 * @param   e:CustomEvent   -	the CustomEvent passed back, including all data in infoObj.
		 *
		 */
		public function changedUI(e:CustomEvent):void {
			trace("caught event "+e);
			switch (e.infoObj.changedProperty) {
				
				case "val":
				
					ExampleModel(getModel()).myFunction(e.infoObj.val);
					break;
				
				//... etc
				
			}
		}
	}
}